From: kfraser@localhost.localdomain Date: Tue, 17 Oct 2006 17:36:26 +0000 (+0100) Subject: It's not correct to call endwin() if initscr() fails, and it crashes X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15589^2~67 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=afe801a3be7876408534f48b21e7e11a799ddf0d;p=xen.git It's not correct to call endwin() if initscr() fails, and it crashes older libcurses implementations. Signed-off-by: John Levon --- diff --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c index 271f4b2bf7..7d3ec59d2e 100644 --- a/tools/xenstat/xentop/xentop.c +++ b/tools/xenstat/xentop/xentop.c @@ -187,6 +187,8 @@ char prompt_val[PROMPT_VAL_LEN]; int prompt_val_len = 0; void (*prompt_complete_func)(char *); +static WINDOW *cwin; + /* * Function definitions */ @@ -223,7 +225,7 @@ static void version(void) /* Clean up any open resources */ static void cleanup(void) { - if(!isendwin()) + if(cwin != NULL && !isendwin()) endwin(); if(prev_node != NULL) xenstat_free_node(prev_node); @@ -236,7 +238,7 @@ static void cleanup(void) /* Display the given message and gracefully exit */ static void fail(const char *str) { - if(!isendwin()) + if(cwin != NULL && !isendwin()) endwin(); fprintf(stderr, str); exit(1); @@ -1029,7 +1031,7 @@ int main(int argc, char **argv) if (!batch) { /* Begin curses stuff */ - initscr(); + cwin = initscr(); start_color(); cbreak(); noecho();